package com.one.group.admin.controller;

import com.one.group.enums.ErrorCode;
import com.one.group.model.vo.UnitManagementVo;
import com.one.group.result.Result;
import com.one.group.service.SpUnitService;
import com.one.group.utils.ResultUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/spUnit")
@Tag(name = "单元接口")
public class SpUnitController {
    @Autowired
    private SpUnitService spUnitService;
    @GetMapping("/list")
    @Operation(summary = "查询单元列表")
    public Result list(Long buildingId){
        List<UnitManagementVo> unitList = spUnitService.mylist(buildingId);
        if (unitList != null){
            return ResultUtil.success(unitList);
        }
        return ResultUtil.error(ErrorCode.OPERATION_ERROR);
    }

}
